package com.changgou.listener;


import com.changgou.config.RabbitMQConfig;
import com.changgou.service.PageService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class PageListener {

  //监听到队列,有消息..数据库的数据有更改,上架生成静态详情页面
  @Autowired
  private PageService pageService;

  @RabbitListener(queues = RabbitMQConfig.PAGE_CREATE_QUEUE)
  public void receiveMessage(String message) {
    System.out.println("接收到的消息为静态页面的商品id:  " + message);
    //调用业务层方法
    pageService.generateItemPage(message);
  }
}
